from lxml import etree
import paths,os


HOST = ""
SERVER = ""
USER = ""
PASSWORD = ""
DB = ""
DPORT = 0
SPORT  = 0


def load():
    
    global HOST,USER,DB,PASSWORD,DPORT,SPORT,SERVER
    
    xmlstring = file(os.path.join(paths.ROOT_DIR,'config.xml')).read()
    
    all = etree.fromstring(xmlstring)
    
    for a in all:
        HOST = a.find("database-host").text
        USER = a.find("database-user").text
        PASSWORD = a.find("database-password").text
        if PASSWORD is None:
            PASSWORD = ""
        DB = a.find("database-name").text
        DPORT = int(a.find("database-port").text)
        
        SERVER = a.find("server-host").text
        SPORT = int(a.find("server-port").text)



# Zu Hause
#HOST = 'localhost'
#USER = 'postgres'
#PASSWORD = ''
#DB = 'webabgabe1'

# HSRM
#SERVER = 'db.intern.mi.hs-rm.de'
#USER = 'bklem001'
#PASSWORD = 'euerpasswort'
#DB = 'bklem001_web_abgabe1'
